<html>
<head>
<meta charset="UTF-8">
<title>批次信息配置列表</title>
	<link id="easyuiTheme" href="../../static/easyui/themes/bootstrap/easyui.css" rel="stylesheet" type="text/css"/>
	<link href="../../static/easyui/themes/icon.css" rel="stylesheet" type="text/css"/>
	<script src="../../static/easyui/jquery.min.js" type="text/javascript"></script>
	<script src="../../static/easyui/jquery.cookie.js" type="text/javascript"></script>
	<script src="../../static/easyui/ui-theme.js" type="text/javascript"></script>
	<script src="../../static/easyui/jquery.easyui.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../static/easyui/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
	<script src="../../static/plugin/assets/jslib.util.js" type="text/javascript"></script>
	<script src="../../static/plugin/assets/jslib.jquery.ajax.js" type="text/javascript"></script>
	<script src="../../static/plugin/assets/jslib.easyui.util.js" type="text/javascript"></script>
	<script src="../../ffres/dict/all.js" type="text/javascript"></script>
	<link href="../../static/easyui/themes/frameless.css" rel="stylesheet" type="text/css"/>
	<a href="" target="_blank" id="commonLink" name="commonLink"></a>
<script type="text/javascript">

    $(function() {
        menuFuncOp($.getUrlParam('funcOpStr'));
    });

    //根据用户拥有的资源操作权限信息，动态控制按钮
    function menuFuncOp(funcOpStr) {
        if(null != funcOpStr && "" != funcOpStr){
            var linkButtons = document.getElementById("tb").getElementsByClassName("easyui-linkbutton");
            for(var i = 0; i < linkButtons.length; i++){
                if(funcOpStr.indexOf(linkButtons[i].id) == -1){
                    document.getElementById(linkButtons[i].id).style.display = 'none';
                }
            }
        }
    }

	function doAdd(){
		JLEUtil.createModalWin('新增', 'BatBatchInfoConfigAdd.html');
	}
	
	function doUpdate() {
		var row = $('#dg').datagrid('getSelected');
		if (row){
			JLEUtil.createModalWin('修改', 'BatBatchInfoConfigUpdate.html?' + 'batchId=' + row.batchId);
		} else {
			$.messager.alert('提示','请选择一条记录！','info');
		}
	}
	
	function doDelete(){
		var row = $('#dg').datagrid('getSelected');
		if (row) {
			$.messager.confirm('删除提示', '你确定要删除这条记录?', function(r){
				if (r){
					var jsonData = JSON.parse('{'+'"batchId":"' + row.batchId + '"'+'}');
					$.restfulDelete('../../api/bat/batch/info/config', jsonData, function(data) {
						$.messager.alert('提示','记录删除成功!','info');
						$('#dg').datagrid('reload');
					});
				}
			});
		} else {
			$.messager.alert('提示','请选择一条记录！','info');
		}
	}

	function doView(){
		var row = $('#dg').datagrid('getSelected');
		if (row) {
			JLEUtil.createModalWin('详情','BatBatchInfoConfigView.html?' + '&batchId=' + row.batchId);
		} else {
			$.messager.alert('提示','请选择一条记录！','info');
		}
	}
	
	function doConfig(){
		var row = $('#dg').datagrid('getSelected');
		if (row) {
			JLUtil.linkNewPage('BatchConfig.html?' + 'batchId=' + row.batchId+"&batchName="+row.batchName);
		} else {
			$.messager.alert('提示','请选择一条记录！','info');
		}
	}
	
	function statBatch() {
		var row = $('#dg').datagrid('getSelected');
		if (row) {
			//若非手动调度，则进行提示
			if(row.launchType == '1'){
				if(!confirm("该批次的发起方式为【定时调度】,是否确认强制手工发起批次？")){
					return;
				}
			}
			if(row.launchType == '3'){
				if(!confirm("该批次的发起方式为【集中调度】,是否确认强制手工发起批次？")){
					return;
				}
			}
			if(confirm("是否确认要手工发起批次？")){
				var params = {
					batchSerialNo: 'none',//由后台使用时间戳作为批次流水号
					batchId: row.batchId,
					batchAction: 'run'
				}
				$.restfulGet('../../api/bat/batch/info/action/', params, function(data){
					if(data.code == '0') {
						$.messager.alert('提示', data.message,'success');
					} else {
						$.messager.alert('提示', data.message,'error');
					}
				});
			}
		} else {
			$.messager.alert('提示','请选择一条记录！','info');
		}
	}

    function queryList(){
        var subsCode = $.getUrlParam("subsCode");
        var batchId=document.getElementById("batchId").value;
        $('#dg').datagrid({
            queryParams: {
                subsCode: subsCode,
                batchId:batchId,
            }
        });
        $('#dg').datagrid({url : '../../api/bat/batch/info/configs'})
    }

    $(function(){
        var subsCode = $.getUrlParam("subsCode");
        $('#dg').datagrid({
            queryParams: {
                subsCode: subsCode,
            }
        });
        $('#dg').datagrid({url : '../../api/bat/batch/info/configs'})
    });

	function reloadList(){
		$('#dg').datagrid('reload');
		JLEUtil.closewin();
	};	
</script>
</head>
<body class="easyui-layout">
<div data-options="region:'north',title:''" style="height: 40px;">
	<form id="searchForm">
		<table>
			<tr>
				<td>&nbsp;批次标识：</td>
				<td><input name="batchId" id="batchId"/></td>
				<td><a class="easyui-linkbutton" href="javascript:void(0);" onclick="queryList()">查找</a></td>
				<td><a class="easyui-linkbutton" href="javascript:void(0);" onclick="JLEUtil.clearForm('searchForm');">清空</a></td>
			</tr>
		</table>
	</form>
</div>
<div data-options="region:'center',split:false">
<table id="dg" class="easyui-datagrid" title="" style="width:100%;height:99%"
			data-options="singleSelect:true,collapsible:true,method:'post'"
			toolbar="#tb"
		title="Load Data" 
		rownumbers="true" pagination="true" pageSize="20">
		<thead>
			<tr>
				<th data-options="field:'batchId',resizable:true" >批次标识</th>
				<th data-options="field:'batchName',resizable:true" >批次名称</th>
				<th data-options="field:'subsCode',resizable:true" >系统代码</th>
				<th data-options="field:'launchType',resizable:true" formatter="formatter_BAT_LAUNCH_TYPE">发起方式</th>
				<th data-options="field:'batchCronValue',resizable:true" >执行周期</th>
				<th data-options="field:'validDate',resizable:true" >生效日期</th>
				<th data-options="field:'equallyTaskAmount',resizable:true" >任务并发数</th>
				<th data-options="field:'isRunAgain',resizable:true" formatter="formatter_STD_PUB_YN">是否允许重跑</th>
				<th data-options="field:'agentId',resizable:true" >执行节点标识</th>
				<th data-options="field:'remark',resizable:true" >备注</th>
			</tr>
		</thead>
	</table>
</div>
<div id="tb" style="padding:1px">
	<div style="margin-bottom:2px">
		<a href="javascript:doAdd()" class="easyui-linkbutton" iconCls="icon-add" plain="true" id="create">新增</a>
		<a href="javascript:doUpdate()" class="easyui-linkbutton" iconCls="icon-edit" plain="true" id="modify">修改</a>
		<a href="javascript:doDelete()" class="easyui-linkbutton" iconCls="icon-remove" plain="true" id="delete">删除</a>
		<a href="javascript:doView()" class="easyui-linkbutton" iconCls="icon-ok" plain="true" id="detail">查看</a>
		<a href="javascript:doConfig()" class="easyui-linkbutton" iconCls="icon-ok" plain="true" id="config">批次配置</a>
		<a href="javascript:statBatch()" class="easyui-linkbutton" iconCls="icon-ok" plain="true" id="start">发起批次</a>
	</div>
</div>
</body>
</html>
